package org.openems.entity;

import java.util.Arrays;

public class TraceEntity extends AbstractEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7703418193369098296L;

	private Double[] data;
	private String verticalAxisName = "";
	private String horizontalAxisName = "";
	private Double horizontalMin = 0.0;
	private Double horizontalMax = 0.0;
	
	@Override
	public boolean equals(Object obj) {
		TraceEntity newObj = (TraceEntity)obj;
		return this.data != null && 
				(this.data.equals(newObj.data) &&
				this.horizontalAxisName.equals(newObj.horizontalAxisName) &&
				this.horizontalMax.equals(newObj.horizontalMax) &&
				this.horizontalMin.equals(newObj.horizontalMin));
	}

	@Override
	protected TraceEntity clone() {
		try {
			TraceEntity ret = (TraceEntity) super.clone();
			if (data != null) {
				ret.setData(Arrays.copyOf(this.data, data.length));
			}
			return ret;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return null;
	}

	public Double getHorizontalMin() {
		return horizontalMin;
	}

	public void setHorizontalMin(Double horizontalMin) {
		this.horizontalMin = horizontalMin;
	}

	public Double getHorizontalMax() {
		return horizontalMax;
	}

	public void setHorizontalMax(Double horizontalMax) {
		this.horizontalMax = horizontalMax;
	}

	public String getVerticalAxisName() {
		return verticalAxisName;
	}

	public void setVerticalAxisName(String verticalAxisName) {
		this.verticalAxisName = verticalAxisName;
	}

	public String getHorizontalAxisName() {
		return horizontalAxisName;
	}

	public void setHorizontalAxisName(String horizontalAxisName) {
		this.horizontalAxisName = horizontalAxisName;
	}

	public Double[] getData() {
		return data;
	}

	public void setData(Double[] data) {
		this.data = data;
//		this.fireEvent();
	}

	
	public TraceEntity(Key key, String name, boolean persisted) {
		super(key, name, persisted);
		// TODO Auto-generated constructor stub
	}

	@Override
	public Entity getClone() {
		return clone();
	}

	@Override
	public String getValueText() {
		return "";
	}

	@Override
	public void setValueText(String text) {
		// TODO Auto-generated method stub
//		this.fireEvent();
	}

}
